package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    public Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);

    @AutoFill(OperationType.UPDATE)
    public void update(Dish dish);

    @Select("SELECT * from dish where id = #{id}")
    public Dish findById(Long id);

    //根据主键id删除菜品数据
    @Delete("delete from dish where id = #{id}")
    void deleteById(Long id);

    void deleteByIds(List<Long> ids);

    List<Dish> list(Dish dish);

    List<Dish> findByCategoryId(Long categoryId,Integer status);
}
